//
// Created by linciping on 2020/9/27.
//
#include "ffmpeg_log.h"

int printfError(int errorCode, const char *tag) {
    char *error = malloc(sizeof(char) * 20);
    av_strerror(errorCode, error, 20);
    printf("%s error message->%s\n", tag, error);
    return 0;
}

void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, const char *tag) {
    AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
    printf("%s: pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
           tag,
           av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
           av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
           av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
           pkt->stream_index);
}